import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Test {
}
class Solution {
    public List<Integer> findPeaks(int[] mountain) {
        List<Integer> ans = new ArrayList<>();
        for(int i=1; i<mountain.length-1; i++){
            if(mountain[i]>mountain[i-1] && mountain[i]>mountain[i+1]){
                ans.add(i);
            }
        }
        return ans;
    }
}
class Solution1 {
    public int minimumAddedCoins(int[] coins, int target) {
        int ans = 0;
        Arrays.sort(coins);
        int max = 0, i = 0;//[0,max]
        while(max < target){
            if(i<coins.length && coins[i]<=max+1){
                max += coins[i];
                i++;
            }else{
                ans++;
                max += max+1;
            }
        }
        return ans;
    }
}
class Solution2 {
    private int f(String s, int k){
        int res = 0;
        for(int i=1; i<=26; i++){
            int size = i * k;
            if(size > s.length()) break;
            int[] c = new int[26];
            for(int j=0; j<size; j++){
                c[s.charAt(j)-'a']++;
            }
            int j=0;
            for(; j<26; j++){
                if(c[j]!=0 && c[j]!=k){
                    break;
                }
            }
            if(j == 26) res += 1;
            for(int in=size, out=0; in<s.length(); in++,out++){
                --c[s.charAt(out)-'a'];
                ++c[s.charAt(in)-'a'];
                j = 0;
                for(; j<26; j++){
                    if(c[j]!=0 && c[j]!=k){
                        break;
                    }
                }
                if(j == 26)res += 1;
            }
        }
        return res;
    }
    public int countCompleteSubstrings(String word, int k) {
        int i = 0;
        int ans = 0;
        while(i<word.length()){
            int start = i;
            i += 1;
            while(i<word.length() && Math.abs((int)word.charAt(i)-(int)word.charAt(i-1))<=2){
                i++;
            }
            ans += f(word.substring(start,i), k);
        }
        return ans;
    }
}